#include <iostream>
#include <queue>
#include <algorithm>
#define fi first
#define se second

using namespace std;
const int N = 1e5 + 5;
typedef pair<int, int> PII;

priority_queue<PII, vector<PII>, greater<PII> > P;
priority_queue<int, vector<int>, greater<int> > Q, O;
PII arr[N];
int ans[N];
signed main() {
    int n, k;
    scanf("%d %d", &k, &n);

    for (int i = 0; i < n; ++ i) 
        scanf("%d %d", &arr[i].fi, &arr[i].se);
    for (int i = 0; i < k; ++ i) Q.push(i);
    sort(arr, arr + n);
    for (int i = 0; i < n; ++ i) {
        if (i % k == 0) while (O.size()) Q.push(O.top()), O.pop();
        while (P.size() && P.top().fi <= arr[i].fi) {
            if (P.top().se >= i % k) Q.push(P.top().se);
            else O.push(P.top().se);
            P.pop();
        }
        if (Q.size()) {
            P.push({arr[i].fi + arr[i].se, Q.top()});
            ans[Q.top()] ++;
            Q.pop();
        } else if (O.size()) {
            P.push({arr[i].fi + arr[i].se, O.top()});
            ans[O.top()] ++;
            O.pop();
        }
    }
    int maxn = 0;
    bool flag = false;
    for (int i = 1; i < k; ++ i) if (ans[maxn] < ans[i]) maxn = i;
    for (int i = 0; i < k; ++ i) if (ans[maxn] == ans[i]) if (flag) printf(" %d", i); else printf("%d", i), flag = !flag;
    system("pause");
    return 0;
}